package problem784;

import java.util.ArrayList;
import java.util.List;

//784.字母大小写全排列
//https://leetcode.cn/problems/letter-case-permutation/

class Solution {
    StringBuffer str = new StringBuffer();
    List<String> ret = new ArrayList<>();
    public List<String> letterCasePermutation(String s) {
        dfs(s, 0);
        return ret;
    }
    public void dfs(String s, int u) {
        if(u == s.length()) {
            ret.add(new String(str));
            return;
        }

        if(s.charAt(u) >= '0' && s.charAt(u) <= '9') {
            str.append(s.charAt(u));
            dfs(s, u+1);
            str.deleteCharAt(str.length()-1);
        }else {
            str.append(Character.toUpperCase(s.charAt(u)));
            dfs(s, u+1);
            str.deleteCharAt(str.length()-1);

            str.append(Character.toLowerCase(s.charAt(u)));
            dfs(s, u+1);
            str.deleteCharAt(str.length()-1);
        }
    }
}